﻿#include "shape.h"

Shape::Shape(QWidget* parent)
	: QWidget(parent)
{
}

bool Shape::scopeDetect(const QPoint& point, int width, int height)
{
	QRect rect(point.x(), point.y(), width, height);
	if (rect.contains(start_point) && rect.contains(QPoint(start_point.x() + shape_width, start_point.y() + shape_height)))
		return true;
	return false;
}

void Shape::setStartPoint(const QPoint& point)
{
	start_point = point;
}

void Shape::setShapeWidth(int width)
{
	shape_width = width;
}

void Shape::setShapeHeight(int height)
{
	shape_height = height;
}

int Shape::getMinX() const
{
	return start_point.x();
}

int Shape::getMaxX() const
{
	return start_point.x() + shape_width;
}

int Shape::getMinY() const
{
	return start_point.y();
}

int Shape::getMaxY() const
{
	return start_point.y() + shape_height;
}

int Shape::getWidth() const
{
	return shape_width;
}

int Shape::getHeight() const
{
	return shape_height;
}

int Shape::getNode() const
{
	return nodes_index;
}

ShapeLink::ShapeLink(QObject* parent, Shape* s_shape, int s_index)
	: QObject(parent),
	start_shape(s_shape),
	start_index(s_index),
	final_shape(nullptr),
	final_index(0)
{
}

void ShapeLink::setFinalShape(Shape* f_shape)
{
	final_shape = f_shape;
}

void ShapeLink::setFinalPoint(QPoint f_point)
{
	final_point = f_point;
}

void ShapeLink::setFinalIndex(int f_index)
{
	final_index = f_index;
}

Shape* ShapeLink::getStartShape() const
{
	return start_shape;
}

Shape* ShapeLink::getFinalShape() const
{
	return final_shape;
}

QPoint ShapeLink::getFinalPoint() const
{
	return final_point;
}

int ShapeLink::getFinalIndex() const
{
	return final_index;
}

int ShapeLink::getStartIndex() const
{
	return start_index;
}
